package com.ym.controller.patient.flow;

import com.github.pagehelper.PageInfo;
import com.ym.common.constant.Constants;
import com.ym.core.annotation.ApiSign;
import com.ym.core.domain.APIResponse;
import com.ym.core.domain.BaseController;
import com.ym.core.shiro.ShiroUtil;
import com.ym.medical.domain.entity.InformationEntity;
import com.ym.medical.domain.param.InformationParam;
import com.ym.medical.domain.vo.FollowupVo;
import com.ym.medical.service.IFollowupSV;
import com.ym.medical.service.IInformationSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author: 张文博
 * @version: 2019年09月03日 9:37
 */

@Controller
@ApiSign
@RequestMapping(value = "/patient/flow",headers= Constants.Api.VERSION)
@Api("患者随访")
public class FllowController extends BaseController {

	@Autowired
	private IFollowupSV iFollowupSV;


	@Autowired
	private IInformationSV iInformationSV;


	@ApiOperation("随访记录信息")
	@GetMapping("/info/message")
	@ResponseBody
	public APIResponse infoMessage(
			@ApiParam(name = "pageNo", value = "页码", required = true)
			@RequestParam(name = "pageNo", required = true, defaultValue = "1")
					int pageNo,
			@ApiParam(name = "pageSize", value = "每页数量", required = false)
			@RequestParam(name = "pageSize", required = false, defaultValue = "10")
					int pageSize,
			@ApiParam(name = "model", value = "model对象", required = false)
					InformationParam model) {
		Long currId = ShiroUtil.getLoginId();
		model.setReceiverObjId(currId);
		PageInfo<InformationEntity> info = iInformationSV.infoMessage(pageNo, pageSize, model);
		return successData(info);


	}


	@ApiOperation("随访内容和优惠券")
	@PostMapping("/follow/message")
	@ResponseBody
	public APIResponse<List<FollowupVo>> followMessage(
			@ApiParam(name = "model", value = "model对象", required = false)
			@RequestBody InformationParam model) {
		List<FollowupVo> followMessage = iFollowupSV.followMessage(model);
		return successData(followMessage);
	}

}
